var app = getApp();
const api = require("../../../utils/api.js");

Page({
  data:{
    
  },
  onLoad: function() {
    
  },
  bindInputBlur: function(e) {
    console.log(e.detail.value);
    var that = this;
    that.setData({
      inputTitle: e.detail.value
    });
  },
  bindTextAreaBlur: function(e) {
    console.log(e.detail.value);
    var that = this;
    that.setData({
      textDetails: e.detail.value
    });
  },
  cancelBtn:function(){
    wx.showModal({
      title: 'Warning~~~要取消吗●ω●',
      content: '确定要取消编辑吗？',
      success: function(res) {
        if (res.confirm) {
          console.log('确认取消编辑');
          wx.switchTab({
            url: '/pages/find/find'
          });
          //console.log(getCurrentPages());
        } else if (res.cancel) {
          console.log('用户点击取消')
        }
      }
    })
  },
  confirmBtn:function(){
    var that = this;
    wx.showModal({
      title: '按确定就可以提交发布啦^ O ^',
      content: '确定提交发布吗？',
      success: function(res) {
        if (res.confirm) {
          console.log('确认提交发布');
          if(that.data.inputTitle && that.data.textDetails){
            console.log("都有值");
            wx.request({
              url: api.issueInterviewExp,
              data:{
                title: that.data.inputTitle,
                content: that.data.textDetails
              },
              header:{
                "sessionid": app.globalData.sessionid,
                "Content-type": "application/json"
              },
              success:function(res){
                console.log(res.data);
              }
            });
            wx.switchTab({
              url: '/pages/find/find'
            });
          } else {
            console.log("有一个为空");
            wx.showToast({
              title: '亲，标题和内容都要填完哦！',
              icon: 'none',
              duration:2000
            })
          }
          
        } else if (res.cancel) {
          console.log('用户点击取消')
          wx.showToast({
            title:"亲继续编辑吧！",
            icon:"success",
            duration:3000
          });
        }
      }
    })
  }
  

})